

USE [master]
GO



ALTER DATABASE [DeploymentSettings] SET COMPATIBILITY_LEVEL = 100
GO

IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [DeploymentSettings].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO

ALTER DATABASE [DeploymentSettings] SET ANSI_NULL_DEFAULT OFF 
GO

ALTER DATABASE [DeploymentSettings] SET ANSI_NULLS OFF 
GO

ALTER DATABASE [DeploymentSettings] SET ANSI_PADDING OFF 
GO

ALTER DATABASE [DeploymentSettings] SET ANSI_WARNINGS OFF 
GO

ALTER DATABASE [DeploymentSettings] SET ARITHABORT OFF 
GO

ALTER DATABASE [DeploymentSettings] SET AUTO_CLOSE OFF 
GO

ALTER DATABASE [DeploymentSettings] SET AUTO_CREATE_STATISTICS ON 
GO

ALTER DATABASE [DeploymentSettings] SET AUTO_SHRINK OFF 
GO

ALTER DATABASE [DeploymentSettings] SET AUTO_UPDATE_STATISTICS ON 
GO

ALTER DATABASE [DeploymentSettings] SET CURSOR_CLOSE_ON_COMMIT OFF 
GO

ALTER DATABASE [DeploymentSettings] SET CURSOR_DEFAULT  GLOBAL 
GO

ALTER DATABASE [DeploymentSettings] SET CONCAT_NULL_YIELDS_NULL OFF 
GO

ALTER DATABASE [DeploymentSettings] SET NUMERIC_ROUNDABORT OFF 
GO

ALTER DATABASE [DeploymentSettings] SET QUOTED_IDENTIFIER OFF 
GO

ALTER DATABASE [DeploymentSettings] SET RECURSIVE_TRIGGERS OFF 
GO

ALTER DATABASE [DeploymentSettings] SET  DISABLE_BROKER 
GO

ALTER DATABASE [DeploymentSettings] SET AUTO_UPDATE_STATISTICS_ASYNC OFF 
GO

ALTER DATABASE [DeploymentSettings] SET DATE_CORRELATION_OPTIMIZATION OFF 
GO

ALTER DATABASE [DeploymentSettings] SET TRUSTWORTHY OFF 
GO

ALTER DATABASE [DeploymentSettings] SET ALLOW_SNAPSHOT_ISOLATION OFF 
GO

ALTER DATABASE [DeploymentSettings] SET PARAMETERIZATION SIMPLE 
GO

ALTER DATABASE [DeploymentSettings] SET READ_COMMITTED_SNAPSHOT OFF 
GO

ALTER DATABASE [DeploymentSettings] SET HONOR_BROKER_PRIORITY OFF 
GO

ALTER DATABASE [DeploymentSettings] SET  READ_WRITE 
GO

ALTER DATABASE [DeploymentSettings] SET RECOVERY FULL 
GO

ALTER DATABASE [DeploymentSettings] SET  MULTI_USER 
GO

ALTER DATABASE [DeploymentSettings] SET PAGE_VERIFY CHECKSUM  
GO

ALTER DATABASE [DeploymentSettings] SET DB_CHAINING OFF 
GO


USE [DeploymentSettings]
GO
/****** Object:  ForeignKey [FK_DeploymentLog_IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DeploymentLog_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[DeploymentLog]'))
ALTER TABLE [dbo].[DeploymentLog] DROP CONSTRAINT [FK_DeploymentLog_IntegrationVersion]
GO
/****** Object:  ForeignKey [FK_IntegrationVersion_Integration]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersion_Integration]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]'))
ALTER TABLE [dbo].[IntegrationVersion] DROP CONSTRAINT [FK_IntegrationVersion_Integration]
GO
/****** Object:  ForeignKey [FK_IntegrationVersionSettings_IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersionSettings_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]'))
ALTER TABLE [dbo].[IntegrationVersionSettings] DROP CONSTRAINT [FK_IntegrationVersionSettings_IntegrationVersion]
GO
/****** Object:  Table [dbo].[DeploymentLog]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DeploymentLog_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[DeploymentLog]'))
ALTER TABLE [dbo].[DeploymentLog] DROP CONSTRAINT [FK_DeploymentLog_IntegrationVersion]
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DeploymentLog_CreateDateTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DeploymentLog] DROP CONSTRAINT [DF_DeploymentLog_CreateDateTime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentLog]') AND type in (N'U'))
DROP TABLE [dbo].[DeploymentLog]
GO
/****** Object:  Table [dbo].[IntegrationVersionSettings]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersionSettings_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]'))
ALTER TABLE [dbo].[IntegrationVersionSettings] DROP CONSTRAINT [FK_IntegrationVersionSettings_IntegrationVersion]
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_IntegrationVersionSettings_CreatedDateTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[IntegrationVersionSettings] DROP CONSTRAINT [DF_IntegrationVersionSettings_CreatedDateTime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]') AND type in (N'U'))
DROP TABLE [dbo].[IntegrationVersionSettings]
GO
/****** Object:  Table [dbo].[IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersion_Integration]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]'))
ALTER TABLE [dbo].[IntegrationVersion] DROP CONSTRAINT [FK_IntegrationVersion_Integration]
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_IntegrationVersion_CreateDateTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[IntegrationVersion] DROP CONSTRAINT [DF_IntegrationVersion_CreateDateTime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]') AND type in (N'U'))
DROP TABLE [dbo].[IntegrationVersion]
GO
/****** Object:  Table [dbo].[Integration]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_Integration_CreateDateTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[Integration] DROP CONSTRAINT [DF_Integration_CreateDateTime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Integration]') AND type in (N'U'))
DROP TABLE [dbo].[Integration]
GO
/****** Object:  Table [dbo].[DefaultSettings]    Script Date: 01/28/2014 10:26:38 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_DefaultSettings_CreatedDateTime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[DefaultSettings] DROP CONSTRAINT [DF_DefaultSettings_CreatedDateTime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DefaultSettings]') AND type in (N'U'))
DROP TABLE [dbo].[DefaultSettings]
GO
/****** Object:  Table [dbo].[DefaultSettings]    Script Date: 01/28/2014 10:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DefaultSettings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DefaultSettings](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[ParameterName] [varchar](150) NOT NULL,
	[DefaultValue] [nvarchar](500) NULL,
	[DevValue] [nvarchar](500) NULL,
	[TestValue] [nvarchar](500) NULL,
	[AccValue] [nvarchar](500) NULL,
	[ProdValue] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NOT NULL CONSTRAINT [DF_DefaultSettings_CreatedDateTime]  DEFAULT (getdate()),
 CONSTRAINT [PK_DefaultSettings] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[DefaultSettings] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [dbo].[Integration]    Script Date: 01/28/2014 10:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Integration]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[Integration](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Name] [nvarchar](500) NOT NULL,
	[Description] [nvarchar](500) NULL,
	[ProductUpgradeCode] [uniqueidentifier] NOT NULL,
	[CreateDateTime] [datetime] NOT NULL CONSTRAINT [DF_Integration_CreateDateTime]  DEFAULT (getdate()),
 CONSTRAINT [PK_Integration] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY],
 CONSTRAINT [UK_Integration_ProductUpgradeCode] UNIQUE NONCLUSTERED 
(
	[ProductUpgradeCode] DESC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[IntegrationVersion](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[IntegrationID] [int] NOT NULL,
	[ProductId] [uniqueidentifier] NOT NULL,
	[Version] [nvarchar](20) NOT NULL,
	[Description] [nvarchar](500) NULL,
	[CreateDateTime] [datetime] NOT NULL CONSTRAINT [DF_IntegrationVersion_CreateDateTime]  DEFAULT (getdate()),
 CONSTRAINT [PK_IntegrationVersion] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[IntegrationVersionSettings]    Script Date: 01/28/2014 10:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[IntegrationVersionSettings](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[IntegrationVersionID] [int] NOT NULL,
	[ParameterName] [varchar](150) NOT NULL,
	[DefaultValue] [nvarchar](500) NULL,
	[DevValue] [nvarchar](500) NULL,
	[TestValue] [nvarchar](500) NULL,
	[AccValue] [nvarchar](500) NULL,
	[ProdValue] [nvarchar](500) NULL,
	[CreatedDateTime] [datetime] NOT NULL CONSTRAINT [DF_IntegrationVersionSettings_CreatedDateTime]  DEFAULT (getdate()),
 CONSTRAINT [PK_IntegrationVersionSettings] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[IntegrationVersionSettings] SET (LOCK_ESCALATION = AUTO)
GO
/****** Object:  Table [dbo].[DeploymentLog]    Script Date: 01/28/2014 10:26:38 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeploymentLog]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[DeploymentLog](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[Type] [nvarchar](1) NOT NULL,
	[IntegrationVersionID] [int] NOT NULL,
	[MachineName] [nvarchar](50) NOT NULL,
	[Environment] [nvarchar](50) NOT NULL,
	[CreateDateTime] [datetime] NOT NULL CONSTRAINT [DF_DeploymentLog_CreateDateTime]  DEFAULT (getdate()),
	[DeployedBy] [nvarchar](100) NOT NULL,
 CONSTRAINT [PK_DeploymentLog] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  ForeignKey [FK_DeploymentLog_IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DeploymentLog_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[DeploymentLog]'))
ALTER TABLE [dbo].[DeploymentLog]  WITH CHECK ADD  CONSTRAINT [FK_DeploymentLog_IntegrationVersion] FOREIGN KEY([IntegrationVersionID])
REFERENCES [dbo].[IntegrationVersion] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_DeploymentLog_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[DeploymentLog]'))
ALTER TABLE [dbo].[DeploymentLog] CHECK CONSTRAINT [FK_DeploymentLog_IntegrationVersion]
GO
/****** Object:  ForeignKey [FK_IntegrationVersion_Integration]    Script Date: 01/28/2014 10:26:38 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersion_Integration]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]'))
ALTER TABLE [dbo].[IntegrationVersion]  WITH CHECK ADD  CONSTRAINT [FK_IntegrationVersion_Integration] FOREIGN KEY([IntegrationID])
REFERENCES [dbo].[Integration] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersion_Integration]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersion]'))
ALTER TABLE [dbo].[IntegrationVersion] CHECK CONSTRAINT [FK_IntegrationVersion_Integration]
GO
/****** Object:  ForeignKey [FK_IntegrationVersionSettings_IntegrationVersion]    Script Date: 01/28/2014 10:26:38 ******/
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersionSettings_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]'))
ALTER TABLE [dbo].[IntegrationVersionSettings]  WITH CHECK ADD  CONSTRAINT [FK_IntegrationVersionSettings_IntegrationVersion] FOREIGN KEY([IntegrationVersionID])
REFERENCES [dbo].[IntegrationVersion] ([ID])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
IF  EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_IntegrationVersionSettings_IntegrationVersion]') AND parent_object_id = OBJECT_ID(N'[dbo].[IntegrationVersionSettings]'))
ALTER TABLE [dbo].[IntegrationVersionSettings] CHECK CONSTRAINT [FK_IntegrationVersionSettings_IntegrationVersion]
GO
